home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ghostscript / src / gxxfont.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  5KB  |  133 lines

  1. /* Copyright (C) 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gxxfont.h */
  20. /* External font interface for Ghostscript library */
  21. #include "gsccode.h"
  22. #include "gsmatrix.h"
  23. #include "gsuid.h"
  24. #include "gsxfont.h"
  25.  
  26. /*
  27.  *            Design issues for external fonts
  28.  *
  29.  * 1. Where do xfonts come from: a device or a font service?
  30.  *
  31.  * 2. Is a given xfont associated with a particular device, or with a
  32.  *    class of devices, which may have different output media?
  33.  *    (Specifically, Windows displays vs. printers.)
  34.  *
  35.  * 3. Is an xfont a handle that must be interpreted by its originator,
  36.  *    or an object with its own set of operations?
  37.  *
  38.  * 4. Are xfonts always transformation-specific, or is there such a thing
  39.  *    as a scalable xfont?
  40.  *
  41.  * 5. What is the meaning of the transformation matrix supplied when
  42.  *    asking for an xfont?
  43.  *
  44.  *            Answers (for the current design)
  45.  *
  46.  * 1. Devices supply xfonts.  Internal devices (image, null, clipping,
  47.  *    command list, tracing) forward font requests to a real underlying
  48.  *    device.  File format devices should do the same, but right now
  49.  *    they don't.
  50.  *
  51.  * 2. An xfont is not associated with anything: it just provides bitmaps.
  52.  *    Since xfonts are only used at small sizes and low resolutions,
  53.  *    tuning differences for different output media aren't likely to be
  54.  *    an issue.
  55.  *
  56.  * 3. Xfonts are objects.  They are allocated by their originator, and
  57.  *    (currently) never freed.
  58.  *
  59.  * 4. Xfonts are always transformation-specific.  This may lead to some
  60.  *    clutter, but it's very unlikely that a document will have enough
  61.  *    different transformed versions of a single font for this to be a
  62.  *    problem in practice.
  63.  *
  64.  * 5. The transformation matrix is the CTM within the BuildChar or BuildGlyph
  65.  *    procedure.  This maps a 1000x1000 square to the intended character size
  66.  *    (assuming the base font uses the usual 1000-unit scaling).
  67.  */
  68.  
  69. /* The definitions for xfonts are very similar to those for devices. */
  70.  
  71. /* Structure for generic xfonts. */
  72. typedef struct gx_xfont_common_s {
  73.     gx_xfont_procs *procs;
  74. } gx_xfont_common;
  75. /* A generic xfont. */
  76. struct gx_xfont_s {
  77.     gx_xfont_common common;
  78. };
  79.  
  80. /* Definition of xfont procedures. */
  81.  
  82. struct gx_xfont_procs_s {
  83.  
  84.     /* Look up a font name, UniqueID, and matrix, and return */
  85.     /* an xfont. */
  86.  
  87.     /* NOTE: even though this is defined as an xfont_proc, */
  88.     /* it is actually a `factory' procedure, the only one that */
  89.     /* does not take an xfont * as its first argument. */
  90.  
  91. #define xfont_proc_lookup_font(proc)\
  92.   gx_xfont *proc(P7(gx_device *dev, const byte *fname, uint len,\
  93.     int encoding_index, const gs_uid *puid, const gs_matrix *pmat,\
  94.     const gs_memory_procs *mprocs))
  95.     xfont_proc_lookup_font((*lookup_font));
  96.  
  97.     /* Convert a character name to an xglyph code. */
  98.     /* encoding_index is 0 for StandardEncoding, */
  99.     /* 1 for ISOLatin1Encoding, 2 for SymbolEncoding, */
  100.     /* and -1 for any other encoding.  Either chr or glyph */
  101.     /* may be absent (gs_no_char/glyph), but not both. */
  102.  
  103. #define xfont_proc_char_xglyph(proc)\
  104.   gx_xglyph proc(P5(gx_xfont *xf, gs_char chr, int encoding_index,\
  105.     gs_glyph glyph, gs_proc_glyph_name((*glyph_name))))
  106.     xfont_proc_char_xglyph((*char_xglyph));
  107.  
  108.     /* Get the metrics for a character. */
  109.  
  110. #define xfont_proc_char_metrics(proc)\
  111.   int proc(P5(gx_xfont *xf, gx_xglyph xg, int wmode,\
  112.     gs_int_point *pwidth, gs_int_rect *pbbox))
  113.     xfont_proc_char_metrics((*char_metrics));
  114.  
  115.     /* Render a character. */
  116.     /* (x,y) corresponds to the character origin. */
  117.     /* The target may be any Ghostscript device. */
  118.  
  119. #define xfont_proc_render_char(proc)\
  120.   int proc(P7(gx_xfont *xf, gx_xglyph xg, gx_device *target,\
  121.     int x, int y, gx_color_index color, int required))
  122.     xfont_proc_render_char((*render_char));
  123.  
  124.     /* Release any external resources associated with an xfont. */
  125.     /* If mprocs is not NULL, also free any storage */
  126.     /* allocated by lookup_font (including the xfont itself). */
  127.  
  128. #define xfont_proc_release(proc)\
  129.   int proc(P2(gx_xfont *xf, const gs_memory_procs *mprocs))
  130.     xfont_proc_release((*release));
  131.  
  132. };
  133.